#include <myheader.h>

/* Usage:  */
int main(int argc, char *argv[]){                                  
    int fd=open("1.txt",O_RDWR);
    int fd2=open("2.txt",O_RDWR);    
    ERROR_CHECK(fd,-1,"open");
    ERROR_CHECK(fd2,-1,"open");
    
    char buf[100]={0};
    //往2.txt里面写数据
    while(1){
        read(0,buf,sizeof(buf));
        write(fd2,buf,strlen(buf));
        memset(buf,0,sizeof(buf));
            
        //从1.txt里面读数据
        while(1){
            ssize_t sret=read(fd,buf,sizeof(buf)); 
            if(sret>0){
            printf("%s",buf);    
            memset(buf,0,sizeof(buf));
            break;
            }
    }
    }
    close(fd);    


    return 0;
}
